import {ModalForm, ProFormDigit, ProFormSelect, ProFormText} from '@ant-design/pro-components';

export interface FormValueType extends Partial<API.AddDelay> {
  jobClassName: string;
  target?: string;
  template?: string;
  type?: string;
  time?: string;
  frequency?: string;
}


export interface EditFormProps {
  onOpenChange: (flag?: boolean, formVals?: FormValueType) => void;
  onSubmit: (values: FormValueType) => Promise<void>;
  jobMetasEnum: Partial<Record<string, { text: string; status: string }>>;
  modalVisible: boolean;
}


export default (props:EditFormProps) => {

  return (
      <ModalForm
        title= "添加延时任务"
        open={props.modalVisible}
        onOpenChange={props.onOpenChange}
        onFinish={props.onSubmit}
    >
       <ProFormText
        width="md"
        name="jName"
        label="任务名"
        rules={[
          { required: true, message: '请输入任务名' },
        ]}
      />
      <ProFormSelect
        width="md"
        name="jobBeanClass"
        label="任务元数据"
        valueEnum={props.jobMetasEnum}
        rules={[
          { required: true, message: '请输入任务元数据' },
        ]}
      />
      <ProFormDigit
        width="md"
        name="delaySeconds"
        tooltip='秒'
        label="延时时间"
        fieldProps={{
          addonAfter: "秒",
        }}
        initialValue={10}
      />
    </ModalForm>
  );
};
